package com.darksides.lendit.dao.utils;

import java.util.Date;

import com.darksides.lendit.dao.jdo.entity.UserEntity;

public class DAOUtils {

	/**
	 * @param o
	 * @param creationUser
	 */
	public void setUpdateFields(Object o, String creationUser) {
		
		Date now = new Date();
		
		if (o instanceof UserEntity) {
			((UserEntity)o).setLastChangeDate(now);
			((UserEntity)o).setLastChangeUser(creationUser);
		} else {
			//ERROR !!!
		}
		
	}
	
	/**
	 * @param o
	 * @param creationUser
	 */
	public void setInsertFields(Object o, String creationUser) {
		
		Date now = new Date();
		
		if (o instanceof UserEntity) {
			((UserEntity)o).setCreationDate(now);
			((UserEntity)o).setCreationUser(creationUser);
			((UserEntity)o).setLastChangeDate(now);
			((UserEntity)o).setLastChangeUser(creationUser);
		} else {
			//ERROR !!!
		}
		
	}
	
}
